<!-- 待收货 -->
<template>
	<view class="">
		<view class="flex flex-column align-end">
			<view class="flex align-center u-p-y-10">
				<text class="u-m-r-30 u-p-y-10">共计{{item.goods.length}}件</text>
				<text class="u-font-30 u-m-r-5">合计</text>
				<text class="u-font-30 text-danger"> ¥{{item.pay_price}}</text>
			</view>
		</view>
		<view class="flex justify-end text-center">
			<!-- <template v-if="!is_weiquan">
				<dy-button width="140rpx" backgroundColor="#fff" color="#333" borderColor="#C2C5C8" @click='btnOrder'>申请售后</dy-button>
			</template> -->
			<dy-button class="u-m-l-30" width="140rpx" @click='toParcel'>查看物流</dy-button>
			<dy-button class="u-m-l-30" width="140rpx" v-if="!item.refundinfo" @click="show = true">确认收货</dy-button>
		</view>

		<u-modal v-model="show" ref="uModal" :show-title="false" :showCancelButton="false" :showConfirmButton="false">
			<view class="flex flex-column align-center u-p-x-30">
				<text class="font-30 font-weight-bold u-p-y-40">确定收货商家的货吗？</text>
				<text class="font-30 text-center" style="width: 500rpx;">为保障您的售后权益，请收到货并确认无误后，再确认收货。</text>
				<view class="flex align-center justify-evenly u-p-y-30">
					<dy-button class="u-m-r-30" size="medium" backgroundColor="#fff" color="#222" borderColor="#222"
						@click="show = false">取消</dy-button>
					<dy-button size="medium" backgroundColor="#f62b0d" borderColor="#f62b0d"
						@click="receipt">确认收货</dy-button>
				</view>
			</view>

		</u-modal>
	</view>

</template>

<script>
	import {
		OrderCenterApi
	} from '@/api/serves.js'
	export default {
		name: "order-item-waitreceipt",
		props: {
			item: {
				type: Object,
				default () {
					return {}
				}
			},
		},
		data() {
			return {
				show: false
			}
		},
		computed: {
			is_weiquan() {
				if (!this.item.goods) return true
				let flg = this.item.goods.some(v => {
					return v.is_weiquan != 0
				})
				return flg
			}
		},
		methods: {
			receipt() {
				//拉起确认收货组件
				if (wx.openBusinessView && this.item.pay_type == 2 && this.item.transaction_id) {
					if (this.item.freight_status == "20") {
						wx.openBusinessView({
							businessType: 'weappOrderConfirm',
							extraData: {
								transaction_id: this.item.transaction_id
							},
							success() {
								//dosomething
								this.show = false
								uni.$emit('orderClick')
							},
							fail(error) {
								console.log(error, 'error-----')
								//dosomething
							},
						});
					} else {
						this.$Toast("商家尚未发货成功")
					}
				} else {
					this.confirmReceipt()
				}
			},
			confirmReceipt() {
				if (this.item.is_finish == 1) return this.$u.toast('该订单在维权中，请等待商家处理', 2000)
				this.show = false
				uni.showLoading()
				OrderCenterApi.orderFinish({
					id: this.item.id
				}).then(res => {
					uni.hideLoading()
					this.$Toast(res.msg)
					if (res.code == 1) {
						uni.$emit('orderClick')
					}
				})
			},
			toParcel() {
				uni.navigateTo({
					url: '/pages/order/mineOrderParcel/mineOrderParcel?order_no=' + this.item.order_no
				})
			},
			btnOrder(v) {
				let params = {
					type: 2, // 2 可退货换货退款
					order_no: this.item.order_no,
				}
				uni.navigateTo({
					url: '/pages/order/mineOrderAfterApply/mineOrderAfterApply?info=' + JSON.stringify(params)
				})
			},
			toDetail() {
				uni.navigateTo({
					url: '/pages/order/mineOrderDetail/mineOrderDetail?order_no=' + this.item.order_no
				})
			}

		}

	}
</script>

<style scoped lang="scss">
</style>